<!DOCTYPE html>
<html lang="zh-cn" dir="ltr">
    <head><meta charset='utf-8'>
<meta name='viewport' content='width=device-width, initial-scale=1'><meta name='description' content='参考资料 https://doc.qt.io/qt-6.5/windows-building.html https://www.kucoding.com/article/149 (Qt6.5.3静态编译与使用-酷编程) https://blog.csdn.net/weixin_50964512/article/details/124746458 (Qt 静态编译与使用（6.2 详解版）) https://zhuanlan.zhihu.com/p/630112083 (QT6 opensource安装详解) 下载源码包 https://download.qt.io/archive/qt/6.5/6.5.3/single/qt-everywhere-src-6.5.3.zip 安装b'>
<title>Qt6编译(MinGW-w64)</title>

<link rel='canonical' href='https://ypr.gitee.io/p/prog/cpp-qt6compile-mingw-w64/'>

<link rel="stylesheet" href="/scss/style.min.abbd69b2908fdfcd5179898beaafd374514a86538d81639ddd2c58c06ae54e40.css"><meta property='og:title' content='Qt6编译(MinGW-w64)'>
<meta property='og:description' content='参考资料 https://doc.qt.io/qt-6.5/windows-building.html https://www.kucoding.com/article/149 (Qt6.5.3静态编译与使用-酷编程) https://blog.csdn.net/weixin_50964512/article/details/124746458 (Qt 静态编译与使用（6.2 详解版）) https://zhuanlan.zhihu.com/p/630112083 (QT6 opensource安装详解) 下载源码包 https://download.qt.io/archive/qt/6.5/6.5.3/single/qt-everywhere-src-6.5.3.zip 安装b'>
<meta property='og:url' content='https://ypr.gitee.io/p/prog/cpp-qt6compile-mingw-w64/'>
<meta property='og:site_name' content='天远博客'>
<meta property='og:type' content='article'><meta property='article:section' content='Post' /><meta property='article:tag' content='编程' /><meta property='article:tag' content='C&#43;&#43;' /><meta property='article:tag' content='Qt' /><meta property='article:tag' content='编译' /><meta property='article:tag' content='静态库' /><meta property='article:published_time' content='2023-11-24T13:00:21&#43;08:00'/><meta property='article:modified_time' content='2023-11-28T14:00:21&#43;08:00'/>
<meta name="twitter:title" content="Qt6编译(MinGW-w64)">
<meta name="twitter:description" content="参考资料 https://doc.qt.io/qt-6.5/windows-building.html https://www.kucoding.com/article/149 (Qt6.5.3静态编译与使用-酷编程) https://blog.csdn.net/weixin_50964512/article/details/124746458 (Qt 静态编译与使用（6.2 详解版）) https://zhuanlan.zhihu.com/p/630112083 (QT6 opensource安装详解) 下载源码包 https://download.qt.io/archive/qt/6.5/6.5.3/single/qt-everywhere-src-6.5.3.zip 安装b">
    </head>
    <body class="
    article-page
    ">
    <script>
        (function() {
            const colorSchemeKey = 'StackColorScheme';
            if(!localStorage.getItem(colorSchemeKey)){
                localStorage.setItem(colorSchemeKey, "auto");
            }
        })();
    </script><script>
    (function() {
        const colorSchemeKey = 'StackColorScheme';
        const colorSchemeItem = localStorage.getItem(colorSchemeKey);
        const supportDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches === true;

        if (colorSchemeItem == 'dark' || colorSchemeItem === 'auto' && supportDarkMode) {
            

            document.documentElement.dataset.scheme = 'dark';
        } else {
            document.documentElement.dataset.scheme = 'light';
        }
    })();
</script>
<div class="container main-container flex on-phone--column extended"><aside class="sidebar left-sidebar sticky ">
    <button class="hamburger hamburger--spin" type="button" id="toggle-menu" aria-label="切换菜单">
        <span class="hamburger-box">
            <span class="hamburger-inner"></span>
        </span>
    </button>

    <header>
        
            
            <figure class="site-avatar">
                <a href="/">
                
                    
                    
                    
                        
                        <img src="/img/TianYuan_hu00d35ae089bda3bce539f572b00404d0_57842_300x0_resize_box_3.png" width="300"
                            height="300" class="site-logo" loading="lazy" alt="Avatar">
                    
                
                </a>
                
            </figure>
            
        
        
        <div class="site-meta">
            <h1 class="site-name"><a href="/">天远博客</a></h1>
            <h2 class="site-description">专注于技术沉淀！！！</h2>
        </div>
    </header><ol class="social-menu">
            
                <li>
                    <a 
                        href='https://github.com/yuanpeirong'
                        target="_blank"
                        title="GitHub"
                        rel="me"
                    >
                        
                        
                            <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-brand-github" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
  <path d="M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" />
</svg>



                        
                    </a>
                </li>
            
                <li>
                    <a 
                        href='http://www.yprnet.com'
                        target="_blank"
                        title="天远网站"
                        rel="me"
                    >
                        
                        
                            <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-home" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <polyline points="5 12 3 12 12 3 21 12 19 12" />
  <path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
  <path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
</svg>



                        
                    </a>
                </li>
            
        </ol><ol class="menu" id="main-menu">
        
        
        
        <li >
            <a href='/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-home" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <polyline points="5 12 3 12 12 3 21 12 19 12" />
  <path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-7" />
  <path d="M9 21v-6a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v6" />
</svg>



                
                <span>主页</span>
            </a>
        </li>
        
        
        <li >
            <a href='/about/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-user" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="12" cy="7" r="4" />
  <path d="M6 21v-2a4 4 0 0 1 4 -4h4a4 4 0 0 1 4 4v2" />
</svg>



                
                <span>关于</span>
            </a>
        </li>
        
        
        <li >
            <a href='/archives/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-archive" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <rect x="3" y="4" width="18" height="4" rx="2" />
  <path d="M5 8v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2 -2v-10" />
  <line x1="10" y1="12" x2="14" y2="12" />
</svg>



                
                <span>归档</span>
            </a>
        </li>
        
        
        <li >
            <a href='/search/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-search" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="10" cy="10" r="7" />
  <line x1="21" y1="21" x2="15" y2="15" />
</svg>



                
                <span>搜索</span>
            </a>
        </li>
        
        
        <li >
            <a href='/links/' >
                
                
                
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-link" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <path d="M10 14a3.5 3.5 0 0 0 5 0l4 -4a3.5 3.5 0 0 0 -5 -5l-.5 .5" />
  <path d="M14 10a3.5 3.5 0 0 0 -5 0l-4 4a3.5 3.5 0 0 0 5 5l.5 -.5" />
</svg>



                
                <span>链接</span>
            </a>
        </li>
        

        <div class="menu-bottom-section">
            
            
                <li id="dark-mode-toggle">
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-toggle-left" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="8" cy="12" r="2" />
  <rect x="2" y="6" width="20" height="12" rx="6" />
</svg>



                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-toggle-right" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="16" cy="12" r="2" />
  <rect x="2" y="6" width="20" height="12" rx="6" />
</svg>



                    <span>暗色模式</span>
                </li>
            
        </div>
    </ol>
</aside>

    

            <main class="main full-width">
    <article class="main-article">
    <header class="article-header">

    <div class="article-details">
    
    <header class="article-category">
        
            <a href="/categories/%E7%BC%96%E7%A8%8B/" >
                编程
            </a>
        
            <a href="/categories/c&#43;&#43;/" >
                C&#43;&#43;
            </a>
        
    </header>
    

    <div class="article-title-wrapper">
        <h2 class="article-title">
            <a href="/p/prog/cpp-qt6compile-mingw-w64/">Qt6编译(MinGW-w64)</a>
        </h2>
    
        
    </div>

    
        <footer class="article-time">
            
                <div>
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-calendar-time" width="56" height="56" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <path d="M11.795 21h-6.795a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4" />
  <circle cx="18" cy="18" r="4" />
  <path d="M15 3v4" />
  <path d="M7 3v4" />
  <path d="M3 11h16" />
  <path d="M18 16.496v1.504l1 1" />
</svg>
                    <time class="article-time--published">2023-11-24</time>
                </div>
            

            
            
                        最后更新:
                        <time class="article-time--updated" datetime="2023-11-28 14:00:21 &#43;0800 CST" title="2023-11-28 14:00:21 &#43;0800 CST">
                            2023-11-28
                        </time>

            
                <div>
                    <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-clock" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="12" cy="12" r="9" />
  <polyline points="12 7 12 12 15 15" />
</svg>



                    <time class="article-time--reading">
                        阅读时长: 4 分钟
                    </time>
                </div>
            
        </footer>
    


    
</div>

</header>

    <section class="article-content">
    
    
    <h1 id="参考资料">参考资料</h1>
<ul>
<li><a class="link" href="https://doc.qt.io/qt-6.5/windows-building.html"  target="_blank" rel="noopener"
    >https://doc.qt.io/qt-6.5/windows-building.html</a></li>
<li><a class="link" href="https://www.kucoding.com/article/149"  target="_blank" rel="noopener"
    >https://www.kucoding.com/article/149</a> (Qt6.5.3静态编译与使用-酷编程)</li>
<li><a class="link" href="https://blog.csdn.net/weixin_50964512/article/details/124746458"  target="_blank" rel="noopener"
    >https://blog.csdn.net/weixin_50964512/article/details/124746458</a> (Qt 静态编译与使用（6.2 详解版）)</li>
<li><a class="link" href="https://zhuanlan.zhihu.com/p/630112083"  target="_blank" rel="noopener"
    >https://zhuanlan.zhihu.com/p/630112083</a> (QT6 opensource安装详解)</li>
</ul>
<h1 id="下载源码包">下载源码包</h1>
<ul>
<li><a class="link" href="https://download.qt.io/archive/qt/6.5/6.5.3/single/qt-everywhere-src-6.5.3.zip"  target="_blank" rel="noopener"
    >https://download.qt.io/archive/qt/6.5/6.5.3/single/qt-everywhere-src-6.5.3.zip</a></li>
</ul>
<h1 id="安装build工具并配置相关环境变量">安装build工具并配置相关环境变量</h1>
<ul>
<li>D:\Qt\Tools\mingw1120_64\bin</li>
<li>CMake	Version 3.16 and newer (3.17 and newer for builds 3.21 and newer for builds)</li>
<li>Ninja</li>
<li>Python	Version 3	Required build tool. Windows installers are available on python.org, or from the Microsoft Store.</li>
</ul>
<h1 id="验证build工具是否正确安装">验证build工具是否正确安装</h1>
<ul>
<li>打开cmd(不要关闭)</li>
<li>输入
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span><span class="lnt">4
</span><span class="lnt">5
</span><span class="lnt">6
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"> <span class="nb">set</span> <span class="nv">PATH</span><span class="o">=</span>D:<span class="se">\Q</span>t<span class="se">\T</span>ools<span class="se">\m</span>ingw1120_64<span class="se">\b</span>in<span class="p">;</span>%PATH%
</span></span><span class="line"><span class="cl"> gcc -v
</span></span><span class="line"><span class="cl"> g++ -v
</span></span><span class="line"><span class="cl"> cmake --version
</span></span><span class="line"><span class="cl"> ninja --version
</span></span><span class="line"><span class="cl"> python -V
</span></span></code></pre></td></tr></table>
</div>
</div></li>
</ul>
<h1 id="设定文件夹">设定文件夹</h1>
<ul>
<li>F:\Qt\6.5.3\src                             源码目录qt-everywhere-src-6.5.3.zip解压，并改名为src，放置于F:\Qt\6.5.3\src</li>
<li>F:\Qt\6.5.3\build-mingw_64      build目录(Release版本)</li>
<li>F:\Qt\6.5.3\build-mingw_64      build目录(Debug版本)</li>
<li>F:\Qt\6.5.3-static\mingw_64     最后安装目录(Release版本)</li>
<li>F:\Qt\6.5.3-static\mingw_64d   最后安装目录(Debug版本)</li>
</ul>
<h1 id="编译release版本">编译Release版本</h1>
<ul>
<li>
<p>建立F:\Qt\qt6mingw_64.cmd文件，需设置好Qt源代码路径、mingw1120_64路径(D:\Qt\Tools\mingw1120_64\bin)</p>
</li>
<li>
<p>建立cmd链接cmd-qt6mingw_64，并运行</p>
<ul>
<li>本步骤主要用途为
<ol>
<li>开启cmd.exe /E:ON /V:ON</li>
<li>将Qt源码相关路径加入PATH</li>
</ol>
</li>
<li>/E:ON  启用命令扩展 详见[<a class="link" href="https://www.cnblogs.com/mq0036/p/5244892.html"  target="_blank" rel="noopener"
    >cmd.exe启动参数说明</a>]</li>
<li>/V:ON  启用延迟的环境变量扩展</li>
</ul>
</li>
<li>
<p>输入</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">F:
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> Qt<span class="se">\6</span>.5.3<span class="se">\b</span>uild-mingw_64 
</span></span></code></pre></td></tr></table>
</div>
</div></li>
<li>
<p>依上述定位到F:\Qt\6.5.3\build-mingw_64</p>
</li>
<li>
<p>依次执行命令</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">..<span class="se">\s</span>rc<span class="se">\c</span>onfigure.bat -static -prefix <span class="s2">&#34;F:\Qt\6.5.3-static\mingw_64&#34;</span> -release -DNDEBUG  <span class="c1">#-DNDEBUG见常见错误</span>
</span></span><span class="line"><span class="cl"> cmake --build .    <span class="c1">#不要忘记点</span>
</span></span><span class="line"><span class="cl"> cmake --install .  <span class="c1">#不要忘记点</span>
</span></span></code></pre></td></tr></table>
</div>
</div></li>
</ul>
<h1 id="编译debug版本">编译Debug版本</h1>
<ul>
<li>关闭上述命令窗口，重新运行cmd链接cmd-qt6mingw_64</li>
<li>输入
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">F:
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> Qt<span class="se">\6</span>.5.3<span class="se">\b</span>uild-mingw_64d   <span class="c1">#注意路径有d</span>
</span></span></code></pre></td></tr></table>
</div>
</div></li>
<li>依上述定位到F:\Qt\6.5.3\build-mingw_64d</li>
<li>依次执行命令
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">..<span class="se">\s</span>rc<span class="se">\c</span>onfigure.bat -static -prefix <span class="s2">&#34;F:\Qt\6.5.3-static\mingw_64d&#34;</span> -debug -DNDEBUG  <span class="c1">#注意路径有d，编译选项为-debug，-DNDEBUG见常见错误</span>
</span></span><span class="line"><span class="cl"> cmake --build .    <span class="c1">#不要忘记点</span>
</span></span><span class="line"><span class="cl"> cmake --install .  <span class="c1">#不要忘记点</span>
</span></span></code></pre></td></tr></table>
</div>
</div></li>
</ul>
<h1 id="编译此段内容为历史记录作废"><del>编译(此段内容为历史记录，作废)</del></h1>
<ul>
<li>
<p>在cmd中(上述不要关闭，否则要重新set PATH=D:\Qt\Tools\mingw1120_64\bin;%PATH%)</p>
</li>
<li>
<p>本步骤在2023-11-23编译时未使用，查看官网文档可将上一步替换优化如下</p>
<ul>
<li>建立F:\Qt\qt6mingw_64.cmd文件，需设置好Qt源代码路径、mingw1120_64路径</li>
<li>建立cmd链接cmd-qt6mingw_64，并运行</li>
<li>比较后，本步骤主要用途为
<ol>
<li>开启cmd.exe /E:ON /V:ON</li>
<li>将Qt源码相关路径加入PATH</li>
</ol>
</li>
<li>/E:ON  启用命令扩展 详见[<a class="link" href="https://www.cnblogs.com/mq0036/p/5244892.html"  target="_blank" rel="noopener"
    >cmd.exe启动参数说明</a>]</li>
<li>/V:ON  启用延迟的环境变量扩展</li>
</ul>
</li>
<li>
<p>输入</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">F:
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> Qt<span class="se">\6</span>.5.3<span class="se">\b</span>uild-mingw_64 
</span></span></code></pre></td></tr></table>
</div>
</div></li>
<li>
<p>依上述定位到F:\Qt\6.5.3\build-mingw_64</p>
</li>
<li>
<p>依次执行命令</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">..<span class="se">\s</span>rc<span class="se">\c</span>onfigure.bat -static -prefix <span class="s2">&#34;F:\Qt\6.5.3-static\mingw_64&#34;</span> -debug-and-release -DNDEBUG  <span class="c1">#见常见错误</span>
</span></span><span class="line"><span class="cl"> cmake --build .    <span class="c1">#不要忘记点</span>
</span></span><span class="line"><span class="cl"> cmake --install .  <span class="c1">#不要忘记点</span>
</span></span></code></pre></td></tr></table>
</div>
</div></li>
</ul>
<h1 id="说明">说明</h1>
<ul>
<li>其中-static就是静态编译的意思，而后面的-debug-and-release，则表示将调试版、发行版都进行编译。</li>
<li>等待配置完成后，再运行命令cmake &ndash;build .开始构建：</li>
<li>然后就是慢慢等编译了，这个过程比较漫长，如果电脑配置较低，估计需要几个小时：</li>
<li>编译完成后，继续运行命令cmake &ndash;install .即可将编译好的静态库安装到前面我们所指定的目录中去：</li>
<li>此时你就可以删除前面的build文件夹，释放110多G的空间，它已经没用了。</li>
</ul>
<h1 id="常见错误">常见错误</h1>
<ul>
<li>ERROR: Exactly one of NDEBUG and _DEBUG needs to be defined</li>
<li>在configure.bat这个命令中，增加-DNDEBUG
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">E:<span class="se">\q</span>t-everywhere-src-6.5.0<span class="se">\q</span>tbase<span class="se">\c</span>onfigure.bat -top-level -release -no-pch -prefix <span class="s2">&#34;E:\Qt\Qt6.5.0&#34;</span> -skip qtwebengine -nomake tools -nomake tests -nomake examples -DNDEBUG
</span></span></code></pre></td></tr></table>
</div>
</div></li>
</ul>
<h1 id="2023-11-23编译已删除"><del>2023-11-23编译(已删除)</del></h1>
<ul>
<li><del>环境：YPR-Desktop、Windows 11 pro 23H2、D:\Qt\Tools\mingw1120_64\bin、约20分钟、2.0GB</del></li>
<li><del>build文件夹约100多GB，已删除</del></li>
<li><del>测试时程序无法Debug：带d版本在build文件夹中已编译，但在camke &ndash;install .时没有被复制过来，参考<a class="link" href="https://www.cnblogs.com/eslzzyl/p/17270948.html"  target="_blank" rel="noopener"
    >VS2022编译安装Qt6.4</a></del></li>
</ul>
<h1 id="2023-11-25编译">2023-11-25编译</h1>
<ul>
<li>环境：YPR-Desktop、Windows 11 pro 23H2、D:\Qt\Tools\mingw1120_64\bin、约15分钟(单独Release或Debug)、Release1.96GB+Debug37.9GB</li>
<li>采用了cmd-qt6mingw_64，分别编译Release和Debug版本</li>
<li>build文件夹：Release55.8GB+Debug120GB，已删除</li>
<li>存档：7z(9-极限压缩）</li>
</ul>

</section>


    <footer class="article-footer">
    
    <section class="article-tags">
        
            <a href="/tags/%E7%BC%96%E7%A8%8B/">编程</a>
        
            <a href="/tags/c&#43;&#43;/">C&#43;&#43;</a>
        
            <a href="/tags/qt/">Qt</a>
        
            <a href="/tags/%E7%BC%96%E8%AF%91/">编译</a>
        
            <a href="/tags/%E9%9D%99%E6%80%81%E5%BA%93/">静态库</a>
        
    </section>
<section class="article-lastmod">
        <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-clock" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="12" cy="12" r="9" />
  <polyline points="12 7 12 12 15 15" />
</svg>



        <span>
            最后更新于 2023-11-28 14:00 CST
        </span>
    </section></footer>
<footer class="article-footer">
    
    <section class="article-copyright">
        <svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-copyright" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
  <path stroke="none" d="M0 0h24v24H0z"/>
  <circle cx="12" cy="12" r="9" />
  <path d="M14.5 9a3.5 4 0 1 0 0 6" />
</svg>



        
		<span>版权声明：本文遵循&ensp;&ensp;<a href="https://creativecommons.org/licenses/by-nc-nd/4.0/deed.zh-hans" target="_blank" rel="noopener">CC BY-NC-ND 4.0 DEED (署名-非商业性使用-禁止演绎4.0国际)</a>&ensp;&ensp;版权协议。</span>
	</section>	
    
</footer>
<footer class="article-footer">
    
    <section class="article-copyright">
        <span>&ensp;&ensp;&ensp;&ensp;&ensp;转载说明：请附上本文链接及上述版权声明。</span>
	</section>	
    
</footer>


    
</article>

    

    

<aside class="related-content--wrapper">
    <h2 class="section-title">相关文章</h2>
    <div class="related-content">
        <div class="flex article-list--tile">
            
                
<article class="">
    <a href="/p/prog/cpp-qt5compile-msvc/">
        
        

        <div class="article-details">
            <h2 class="article-title">Qt5编译(MSVC)</h2>
        </div>
    </a>
</article>

            
                
<article class="">
    <a href="/p/prog/cpp-qt5compile-mingw-w64/">
        
        

        <div class="article-details">
            <h2 class="article-title">Qt5编译(MinGW-w64)</h2>
        </div>
    </a>
</article>

            
                
<article class="">
    <a href="/p/prog/cpp-qt6compile-msvc/">
        
        

        <div class="article-details">
            <h2 class="article-title">Qt6编译(MSVC)</h2>
        </div>
    </a>
</article>

            
                
<article class="">
    <a href="/p/prog/cpp-qt-test-static/">
        
        

        <div class="article-details">
            <h2 class="article-title">测试Qt静态库</h2>
        </div>
    </a>
</article>

            
                
<article class="">
    <a href="/p/prog/cpp-gcc-sharedandstaticlib/">
        
        

        <div class="article-details">
            <h2 class="article-title">GCC上的动态库与静态库</h2>
        </div>
    </a>
</article>

            
        </div>
    </div>
</aside>

     
    
        
    

    <footer class="site-footer">
    
	<section class="copyright">
	    技术交流： <a href="mailto:ypr@yprnet.com" target="_blank" rel="noopener">ypr@yprnet.com</a>、
		<a href="mailto:ypr@yuanpeirong.com" target="_blank" rel="noopener">ypr@yuanpeirong.com</a>
		<br />版权所有 © 2010-2025 <a title="访问天远网站" href="http://www.yprnet.com/" target="_blank" rel="noopener">YuanPeirong TianYuan</a> All Rights Reserved. Powered By <a title="访问天远网站" href="http://www.yprnet.com/" target="_blank" rel="noopener">天远</a>
    </section>
    <section class="powerby">
        Built with <a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo</a> <br />
        主题 <b><a href="https://github.com/CaiJimmy/hugo-theme-stack" target="_blank" rel="noopener" data-version="3.21.0">Stack</a></b> 由 <a href="https://jimmycai.com" target="_blank" rel="noopener">Jimmy</a> 设计 | <a href="http://www.yprnet.com/" target="_blank" rel="noopener">天远</a> 优化修改
    </section>
    <section class="powerby">
        <a target="_blank" href="https://beian.miit.gov.cn">浙ICP备15010776号-3</a>
    </section>
</footer>


    
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    
    <div class="pswp__bg"></div>

    
    <div class="pswp__scroll-wrap">

        
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                
                
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div><script 
                src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"integrity="sha256-ePwmChbbvXbsO02lbM3HoHbSHTHFAeChekF1xKJdleo="crossorigin="anonymous"
                defer
                >
            </script><script 
                src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"integrity="sha256-UKkzOn/w1mBxRmLLGrSeyB4e1xbrp4xylgAWb3M42pU="crossorigin="anonymous"
                defer
                >
            </script><link 
                rel="stylesheet" 
                href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css"crossorigin="anonymous"
            ><link 
                rel="stylesheet" 
                href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css"crossorigin="anonymous"
            >

            </main>
        </div>
        <script 
                src="https://cdn.jsdelivr.net/npm/node-vibrant@3.1.6/dist/vibrant.min.js"integrity="sha256-awcR2jno4kI5X0zL8ex0vi2z&#43;KMkF24hUW8WePSA9HM="crossorigin="anonymous"
                
                >
            </script><script type="text/javascript" src="/ts/main.js" defer></script>
<script>
    (function () {
        const customFont = document.createElement('link');
        customFont.href = "https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap";

        customFont.type = "text/css";
        customFont.rel = "stylesheet";

        document.head.appendChild(customFont);
    }());
</script>

    </body>
</html>
